package edu.office.sessionRepository;

import jakarta.enterprise.context.SessionScoped;
import jakarta.inject.Named;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

/**
 *
 * @author haogs
 */
@Named
@SessionScoped
public class UserMessagor implements java.io.Serializable {

    List<String> messagesList = new LinkedList<>();
    List<String> msgs = new ArrayList<>();

    public void addMessage(String message) {
        System.out.println(message);
        messagesList.add(message);}

    public String getAlertMessage() {
        StringBuilder sb = new StringBuilder();
        messagesList.forEach(mess -> {
            sb.append(mess);
        });
        messagesList.clear();//用完即销毁
        return sb.toString();
    }
}
